﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace SaleOnlineSystem.Admin.Controls
{
    public partial class ListOrder : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                if (!Page.IsPostBack)
                {
                    //Them du lieu vao cat 1

                    rpt_order.DataSource = DAL.DCollector.DBCollector.Instance.StoredProcedureSelectByColumns("tbl_Orders", " * ", "selectbycolumns");

                    rpt_order.DataBind();

                }
            }
            catch (Exception)
            {
                Response.Redirect("/error.htm");
            }           
        }

        protected void rpt_order_ItemCommand(object source, RepeaterCommandEventArgs e)
        {
            try
            {
                if (e.CommandName == "delete")
                {
                    string id = (e.CommandArgument.ToString());
                    DAL.DCollector.DBCollector.Instance.CallStored("callstored", "delete from tbl_OrderLine where Orders_ID='" + id + "'", false);
                    DAL.DCollector.DBCollector.Instance.CallStored("callstored", "delete from tbl_Orders where Orders_ID='" + id + "'", false);
                    Response.Redirect("/Admin/Index.aspx?panel=3&sub=0");
                }
            }
            catch (Exception)
            {
                Response.Redirect("/error.htm");
            }           
        }
    }
}